<template>
  <div class="index">
    <LoginTop/>
    <div class="jh-guid">
      <div class=" hm-bd">
        <span>您当前的位置：</span>
        <a href="javascript:void(0)" @click="$router.push('/index')">首页</a>
        <i>></i>
        <a href="javascript:void(0)" @click="$router.push('/index')">登录</a>
        <i>></i>
        <a href="javascript:void(0)" @click="$router.push('/register')">注册</a>
        <i>></i>
        <a href="javascript:void(0)">激活邮箱</a>
      </div>
    </div>
    <div class="jh-bd">
      <div class="hm-bd jh-con">
        <div class="jh-con-top">
          <div class="jh-c-h">
            <span><img src="../../assets/jh-g.png"></span>
            <span>邮件已发送</span>
          </div>
          <div class="jh-hy">欢迎入驻中亿财经网</div>
          <div class="jh-jr">马上进入邮箱，激活账户完成注册！</div>
          <button v-if="hash[email.split('@')[1]]" class="jh-button" @click="goEmail()">进入邮箱</button>
          <div class="jh-qr">
            确认激活邮件已发送到你的（
            <a href="javascript:void(0)">{{email}}</a>），没有收到邮件，点击
            <a href="javascript:void(0)">
              <span id="rejs">重新发送（
                <i>60</i>秒）</span>
              <span id="resned" style="display: none" @click="sendActivateEmail()">重新发送</span>
            </a>
            <p>点击邮件里的确认连接即可激活您的账号</p>
          </div>
        </div>
      </div>
    </div>
    <Footer/>
  </div>
</template>
<script>
// import $ from 'jquery'
import LoginTop from '@/components/login-top'
import Footer from '@/components/footer'
import * as api from '@/service/api'
export default {
  title: '用户中心-激活邮箱',
  components: {
    LoginTop,
    Footer
  },
  data () {
    return {
      globalThis: null,
      email: null,
      loading: false,
      hash: {
        'qq.com': 'https://mail.qq.com',
        'gmail.com': 'https://mail.google.com',
        'sina.com': 'https://mail.sina.com.cn',
        '163.com': 'https://mail.163.com',
        '126.com': 'https://mail.126.com',
        'yeah.net': 'https://www.yeah.net/',
        'sohu.com': 'https://mail.sohu.com/',
        'tom.com': 'https://mail.tom.com/',
        'sogou.com': 'https://mail.sogou.com/',
        '139.com': 'https://mail.10086.cn/',
        'hotmail.com': 'https://www.hotmail.com',
        'live.com': 'https://login.live.com/',
        'live.cn': 'https://login.live.cn/',
        'live.com.cn': 'https://login.live.com.cn',
        '189.com': 'https://webmail16.189.cn/webmail/',
        'yahoo.com.cn': 'https://mail.cn.yahoo.com/',
        'yahoo.cn': 'https://mail.cn.yahoo.com/',
        'eyou.com': 'https://www.eyou.com/',
        '21cn.com': 'https://mail.21cn.com/',
        '188.com': 'https://www.188.com/',
        'foxmail.com': 'https://www.foxmail.com',
        'outlook.com': 'https://www.outlook.com'
      }
    }
  },
  created () {
    if (this.$route.query.email) {
      this.email = this.$route.query.email
    }
  },
  mounted () {
    this.globalThis = window
    this.globalThis.yzmTime() // 1分钟后重新发送
  },
  methods: {
    async sendActivateEmail () {
      let msgHref = ''
      if (window.location.href.split(window.location.host)[1].slice(0, 9) === '/ucenter/') {
        msgHref = /^(.*\/\/[^/]*\/).*$/.exec(window.location.href)[1] + 'ucenter/'
      } else {
        msgHref = /^(.*\/\/[^/]*\/).*$/.exec(window.location.href)[1]
      }
      try {
        await api.sendActivateEmail({
          email: this.email,
          msg: `欢迎加入中亿财经网，请点击下方链接激活邮件！<br/> ${msgHref}#/registerByEmailSuccess?email=${this.email}`
        })
      } catch (e) {
        console.log(e)
      }
    },
    goEmail () {
      let mail = this.email.split('@')[1]
      if (this.hash[mail]) {
        window.open(this.hash[mail])
      }
    }
  }
}
</script>
<style lang="scss">
.index {
}
</style>
